package mvc.binalee.models;

import java.util.Date;

public class DataBean {
	private static final int SHORT_SUBJECT_LEN = 50;
	private static final int THUMBNAIL_LEN = 100;
	private int bbsNumber = 0;
	private String subject = null;
	private String category = null;
	private String categoryCode = null;
	private String who = null;
	private String createDay = null;
	private String content = null;
	private String shortSubject = null;
	private String tumbnail = null;
	
	
	public int getBbsNumber() {
		return bbsNumber;
	}
	public void setBbsNumber(int bbsNumber) {
		this.bbsNumber = bbsNumber;
	}
	public String getSubject() {
		return subject;
	}
	public void setSubject(String subject) {
		this.subject = subject;
	}
	public String getCategory() {
		return category;
	}
	public void setCategory(String boardName) {
		this.category = boardName;
	}
	public String getCategoryCode() {
		return categoryCode;
	}
	public void setCategoryCode(String categoryCode) {
		this.categoryCode = categoryCode;
	}
	public String getWho() {
		return who;
	}
	public void setWho(String who) {
		this.who = who;
	}
	public String getCreateDay() {
		
		return createDay;
	}
	public void setCreateDay(String createDay) {
		this.createDay = createDay;
	}
	public String getContent() {
		return content;
	}
	public void setContent(String content) {
		this.content = content;
	}
	public String getShortSubject(){
		StringBuffer subjectBuffer = new StringBuffer();
		String subjectString = this.subject;

		if (subjectString.length() > SHORT_SUBJECT_LEN) {
			subjectBuffer.append(subjectString.substring(0, SHORT_SUBJECT_LEN));
			subjectBuffer.append("...");
		} else {
			subjectBuffer.append(subjectString);
		}
		
		return subjectBuffer.toString();
	}
	
	public String getThumbnail(){
		StringBuffer contentThumbnail = new StringBuffer();
		String thumbnailString = this.content;

		if (thumbnailString.length() > THUMBNAIL_LEN) {
			contentThumbnail.append(thumbnailString.substring(0, THUMBNAIL_LEN));
			contentThumbnail.append("...");
		} else {
			contentThumbnail.append(thumbnailString);
		}
		
		return contentThumbnail.toString();
	}
}
